package com.example.stock.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.stock.eo.StockStatEo;
import com.example.stock.eo.StockTradeEo;
import com.example.stock.mapper.StockStatMapper;
import com.example.stock.service.calc.CalcService;
import com.example.stock.vo.DataVo;
import com.example.stock.vo.common.TradeVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author: zorching
 * @Description
 * @Date: 2021/1/2 12:30
 * Copyright (c) 2019 北京新媒传信科技有限公司
 */
@Service
public class StockStatService extends ServiceImpl<StockStatMapper, StockStatEo> {

    @Resource
    private StockTradeService stockTradeService;
    @Resource
    private CalcService calcService;

    public BigDecimal analysisMaCross(int m, int n, List<DataVo> closeData) {
        List<TradeVo> tradeVos = calcService.calcMaCrossTrade(closeData, m,n);
        tradeVos = tradeVos.stream().skip(1000).collect(Collectors.toList());
        return stockTradeService.doTrade(tradeVos, false);
    }

    public BigDecimal analysisEmaAdjust(int m, int n, List<DataVo> closeData, BigDecimal refer) {
        List<TradeVo> tradeVos = calcService.calcEmaAdjustTrade(closeData, m, n,refer);
        tradeVos = tradeVos.stream().skip(1000).collect(Collectors.toList());
        return stockTradeService.doTrade(tradeVos, false);
    }

    public BigDecimal analysisEmaUpDown(int m, int n, List<DataVo> closeData, boolean save) {
        List<TradeVo> tradeVos = calcService.calcEmaTrade(closeData, m, n);
        tradeVos = tradeVos.stream().skip(166).collect(Collectors.toList());
        return stockTradeService.doTrade(tradeVos,save);
    }

    public BigDecimal analysisMaUpDown(int n, List<DataVo> closeData) {
        List<TradeVo> tradeVos = calcService.calcMaTrade(closeData, n);
        tradeVos = tradeVos.stream().skip(1000).collect(Collectors.toList());
        return stockTradeService.doTrade(tradeVos, false);
    }









}
